<template>
  <div class='purchase-list w1200'>
    <p class="title" v-if="showShopInfo">商家信息</p>
    <div class="shop-info" v-if="showShopInfo">
      <img :src="defaultImg" class="shop-logo" alt="">
      <p v-for="(item, index) in modelData0" :key="index" :class="item.class">
        <span v-for="(item1, index1) in item.list" :key="index1" :class="item1.class">{{item1.label}}</span>
      </p>
    </div>

    <p class="title">完善求购内容</p>
    <div class="purchase-table">
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column v-for="(item, index) in tableModel" :key="index" :prop="item.prop" :label="item.label" :min-width="item.width" >
          <template slot-scope="scope">
            <el-select v-if="!item.unit&&!item.btn" v-model="perchaseInfo[item.prop]" placeholder="请选择">

            </el-select>

            <div class="is-unit" v-else-if="item.unit">
              <el-input v-model="perchaseInfo[item.prop]" placeholder="请输入内容"></el-input>
              <el-select v-model="perchaseInfo[item.unitValue]" placeholder=""></el-select>
            </div>

            <div class="is-btn" v-else-if="item.btn">
              <span class="iconfont icon-shanchu color-red hover" @click="doDel(scope)"></span>
              <span class="hover del-btn" @click="doDel(scope)">删除</span>
            </div>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <p class="btn-box">
      <el-button type="success" class="bc-green" @click="addColum">新增求购</el-button>
      <el-upload class="fr" :action="uploadUrl" :limit="1" :on-success="handle" :on-error="handle">
        <el-button type="success" class="bc-green">上传求购文件</el-button>
      </el-upload>
      <el-button type="primary" class="fr bc-blue mr10" @click="download">下载模板</el-button>
    </p>
    <p class="title">备注</p>
    <el-input type="textarea" :rows="5"  placeholder="例如：是否需要开发票？到货日期？"></el-input>
    <p class="title">报价时限</p>
    <div class="radio-box">
      <el-radio v-model="perchaseInfo.time" label="1">半小时</el-radio>
      <el-radio v-model="perchaseInfo.time" label="2">一小时</el-radio>
    </div>

    <div class="sure-box">
      <el-button type="primary" class="bc-blue">发起求购</el-button>
    </div>

    
  </div>
</template>
<script>
export default {
  components: {},
  name: "",
  data() {
    return {
      uploadUrl:"12",//上传文件地址
      showShopInfo:false,
      defaultImg:require('../../assets/imgs/homepage/c_logo.png'),
      modelData0:[
        {
          class:'ft14',
          list:[
            {label:"商铺名称",class:"ft16 color-blue ml15"},
            {label:"",class:"icon-huangguan iconfont color-yellow ml5"},
            {label:"",class:"icon-zuanshi iconfont color-yellow ml5"},
          ]
        },{
          class:"address",
          list:[
            {label:"",class:"icon-zu iconfont color-blue ml5"},
            {label:"地址：",class:"ft14 color-666 ml5"}
          ]
        },{
          class:"register",
          list:[
            {label:"",class:"icon-qiye iconfont color-green ml10"},
            {label:"企业认证",class:"ft14 color-666 ml5 mr10"},
            {label:"",class:"icon-baozhengjin iconfont color-red ml10"},
            {label:"保证金",class:"ft14 color-666 ml5 mr10"},
            {label:"",class:"icon-ercijiagong iconfont color-yellow ml10"},
            {label:"仓储加工",class:"ft14 color-666 ml5"}
          ]
        }
      ],
      tableModel:[
        {prop:"",label:"分类",width:"",},
        {prop:"",label:"品名",width:"",},
        {prop:"",label:"商品名称",width:"",},
        {prop:"",label:"材质",width:"",},
        {prop:"",label:"规格",width:"",},
        {prop:"",label:"数量/单位",width:"100",unit:true,unitArray:[],unitValue:""},
        {prop:"",label:"地区",width:"",},
        {prop:"",label:"操作",btn:true},
      ],
      tableData:[{}],
      perchaseInfo:{
        table:[{},{}],

        time:"1",//报价时限

      },//填写信息
    };
  },
  methods: {
    doDel(scope){
      console.log("删除--",scope.$index);
    },

    /**
     * @name 新增求购
     */
    addColum(){
      this.tableData.push({})
    },

    download(){
      console.log("下载文件模板");
    },

    uploadFile(){
      document.getElementById('upload-file').click()
    },

    /**
     * @name 上传成功或失败回调
     */
    handle(res,file){

    },

    init(){
      this.showShopInfo=this.$router.history.current.query.shopId>0
      console.log(this.showShopInfo);
    }

  },
  created() {
    this.$nextTick(()=>{
      this.init()
    })
  }
};
</script>
<style lang="scss" scoped>
.purchase-list{
  box-sizing: border-box;
  padding: 35px 30px; 
  background-color: #fff;
  box-shadow: 1px 1px 10px 5px #eee;
  transform: translateY(-105px);
  z-index: 10;
  border-radius: 5px;

  .title{
    background-color: #f2f2f2;
    font-size: 16px;
    line-height: 40px;
    text-indent: 10px;
    border-left: 5px solid #2979ff;
    margin: 30px 0;
  }

  .shop-info{
    display: flex;
    line-height: 45px;
    padding: 10px 15px;

    img{
      width: 45px;
      height: 45px;
    }
    p:nth-last-of-type(n+2){
      margin-right: 20px;
    }
  }

  .is-unit{
    display: flex;
  }
  .is-btn{

    .iconfont{
      margin-right: 5px;
    }
    .del-btn{
      color: #999!important;
    }
  }
  .btn-box{
    margin: 30px 0;

    button{
      font-size: 13px;
      width: 135px;
      height: 36px;
      border-radius: 0
    }
  }

  .sure-box{
    margin-top: 80px;
    text-align: center;

    button{
      width: 135px;
      border-radius: 0
    }
  }
}
</style>